﻿using Furion.DynamicApiController;
using Furion.FriendlyException;
using FurionApi.Demo.Application.U_Test.Services;
using FurionApi.Demo.Core;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FurionApi.Demo.Application.U_Test
{
    [Route("utest")]
    [ApiDescriptionSettings(KeepVerb = true, SplitCamelCase = false)]
    public class UTestAppService : IDynamicApiController
    {
        private readonly IUTestService uTestService;

        public UTestAppService(IUTestService uTestService) {
            this.uTestService = uTestService;
        }

        /// <summary>
        /// 获取test
        /// </summary>
        /// <returns></returns>
        [Route("getUTest")]
        public async Task<UTest> GetUTest()
        {
            return await uTestService.GetUTestAsync();
        }

        [Route("getUTestById")]
        public UTest GetUTestById(int id)
        {
            var m = uTestService.GetUTest(id);

            if(m==null)
                throw Oops.Oh($"id: {id} 无效");
            return m;
        }

    }
}
